﻿$(function () {
    $("#typeId").ligerComboBox({
        cancelable: false,
        width: 200,
        valueFieldID: 'hdnTypeId'
    });
});

function save() {
    var id = $("#hdnJobId").val();
    var typeId = $("#hdnTypeId").val();
    var jobTitle = $("#txtJobTitle").val();
    var jobCode = $("#txtJobCode").val();
    var sort = $("#txtSort").val();

    if (IsEmpty(jobTitle)) {
        $.ligerDialog.error("职务名称不能为空");
        $("#txtJobTitle").focus();
        return;
    }
    if (IsEmpty(jobCode)) {
        $.ligerDialog.error("职务编码不能为空");
        $("#txtJobCode").focus();
        return;
    }
   
    $.ajax({
        url: "/Sysbase/Job/Save",
        type: "post",
        data: {
            Id: id,
            TypeId: typeId,
            JobTitle: jobTitle,
            JobCode: jobCode,
            Sort: sort
        },
        success: function (r) {
            var r = $.parseJSON(r);
            if (r.Result == 1) {
                parent.$("#btnSearch").click();
                closeDialog();
            }
            else if (r.Result == 0) {
                $.ligerDialog.error(r.Body);
            }
            else {
                $.ligerDialog.error("程序错误");
            }
        },
        error: function () {
            $.ligerDialog.error("程序错误");
        }
    });
}

function closeDialog() {
    frameElement.dialog.close();//关闭dialog
}